const Joi = require('joi');

const userSchema = Joi.object({
  username: Joi.string().required().min(3).max(50),
  password: Joi.string().required().min(6).max(50),
  role: Joi.string().valid('admin', 'manager', 'staff').default('staff')
});

const validateUser = (req, res, next) => {
  const { error } = userSchema.validate(req.body);
  if (error) {
    return res.status(400).json({
      status: 'error',
      message: error.details[0].message
    });
  }
  next();
};

module.exports = {
  validateUser
}; 